package com.situ.hello;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.nfc.Tag;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.ToggleButton;

// 继承是一个严格的父子关系，你继承什么你就是什么
// Alt+Enter
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "MainActivity";

    private Button widgetBtn;
    private Button toggleBtn;
    private Button linearLayoutBtn;
    private Button logBtn;
    private Button lifeBtn;
    private Button intentBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 绑定布局
        setContentView(R.layout.activity_main);

        widgetBtn = findViewById(R.id.btn_widget);
        toggleBtn = findViewById(R.id.btn_toggle);
        linearLayoutBtn = findViewById(R.id.btn_linear_layout);
        logBtn = findViewById(R.id.btn_log);
        lifeBtn = findViewById(R.id.btn_life);
        intentBtn = findViewById(R.id.btn_intent);

        widgetBtn.setOnClickListener(this);
        toggleBtn.setOnClickListener(this);
        linearLayoutBtn.setOnClickListener(this);
        logBtn.setOnClickListener(this);
        lifeBtn.setOnClickListener(this);
        intentBtn.setOnClickListener(this);

//        widgetBtn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_widget:
                // 跳转到另外一个Activity
                Intent intent1 = new Intent(this, WidgetActivity.class);
                startActivity(intent1);
                break;
            case R.id.btn_toggle:
                Intent intent2 = new Intent(this, ToggleActivity.class);
                startActivity(intent2);
                break;
            case R.id.btn_linear_layout:
                Intent intent3 = new Intent(this, LinearLayoutActivity.class);
                startActivity(intent3);
                break;
            case R.id.btn_log:
                /// syso
                System.out.println("Hello Android");
                Log.d(TAG, "debug");
                Log.i(TAG, "info");
                Log.w(TAG, "warn");
                Log.e(TAG, "error");

                int sum = 0;
                for (int i = 1; i <= 100; i++) {
                    sum += i;
                }
                System.out.println("sum: " + sum);

                break;
            case R.id.btn_life:
                Intent intent4 = new Intent(this, LifeActivity.class);
                startActivity(intent4);
                break;
            case R.id.btn_intent:
                Intent intent5 = new Intent(this, IntentActivity.class);
                intent5.putExtra("extra_data", "Hello IntentActivity");
                startActivity(intent5);
                break;
        }
    }
}
